package cn.rokhdelar.ams.management.domain.po;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

public class LoginUser extends SysUser implements UserDetails {
    Collection<? extends GrantedAuthority> authorities;

    public LoginUser(SysUser sysUser, Collection<? extends GrantedAuthority> authorities) {
        if (sysUser != null) {
            this.setId(sysUser.getId());
            this.setUsername(sysUser.getUsername());
            this.setPassword(sysUser.getPassword());
            this.setName(sysUser.getName());
            this.authorities = authorities;
        }
    }


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.authorities;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
